/**
* @file nav_struct.h in loosely_couple_h7
* @author rebeater
* @comment
* Create on 2021/1/24 下午5:53
* @version 1.0
**/

//
// Created by rebeater on 2021/1/24.
//

#ifndef LOOSELY_COUPLE_H7_NAV_STRUCT_H
#define LOOSELY_COUPLE_H7_NAV_STRUCT_H
#define _PI 3.1415926535897932
#define _hour 3600
#define _minute 60
#define _sqrt_h 60
#define _deg (_PI/180.0)
#define _mGal (1e-5)
#define _ppm (1e-6)
#define _knot (0.5144444)
#include "../Inc/global_defines.h"
typedef struct {
  float acce_bias[3];
  float gyro_bias[3];
} Bias;

typedef struct {
  double gpst;
  double gyro[3];
  double acce[3];
} ImuData;

typedef enum {
  INITIAL = 0,
  SPP = 1,
  RTK_DGPS = 2,
  UNKNOWN_PPS = 3,
  RTK_FIX = 4,
  RTK_FLOAT = 5,
  INVALID = 6,
} GnssMode;

typedef enum {
  SYSTEM_START,
  SYSTEM_WAIT_FOR_TIME,
  SYSTEM_ALIGNING,
  SYSTEM_NAVIGATION,
  SYSTEM_WARNING,
  SYSTEM_ERROR,
} SystemState;

typedef struct {
  double lat;
  double lon;
  float height; /*32*/
  float pos_std[3];
  float yaw;/*0~360,-1表示无效*/
  float pitch;
  short pitch_std_100;
  short yaw_std_100;/*32 + 4*6 = 56 */
  short week;/*4*/
  unsigned char ns; /*大于128不可能！！！*/
  unsigned char mode; /*  和 NMEA的模式定义保持一致*/
//  unsigned char reserved[24];
} GnssData;/*64 bytes*/

typedef struct {
  float arw;
  float vrw;
  float ab_ini[3];
  float gb_ini[3];
  float as_ini[3];
  float gs_ini[3];
  float ab_std;
  float gb_std;
  float gs_std;
  float as_std;
  float at_corr;
  float gt_corr;
} ImuPara;
typedef enum {
  IMU_FORMAT_IMD = 0,
  IMU_FORMAT_IMUTXT = 1
} ImuFileFormat;
typedef enum {
  GNSS_TXT_POS_7 = 0,
  GNSS_BIN_POS_7 = 1,
  GNSS_TXT_POS_14 = 2,
  GNSS_BIN_POS_14 = 3,
  RTKLIB_TXT_POS = 4,
  GNSS_TXT_POS_VEL = 5,
  GNSS_TXT_GGA = 6,
  RESERVED = 6,
} GnssFileFormat;
typedef struct {
  unsigned short sensors;
  unsigned short mode;
} NavInfo;
typedef struct {
  double lat;
  double lon;
  float vn[3];
  float atti[3];
  NavInfo info;
  float height;
} NavOutput;
/*sizeof(NavOutput)=128*/
typedef struct {
  double latitude;
  double longitude;
} LatLon;
typedef struct {
  double gpst;
  double lat;
  double lon;
  float h;
  float vn;
  float ve;
  float vd;
  float roll;
  float pitch;
  float yaw;
  float ab[3];
  float gb[3];
  NavInfo info;
/*    double pos_std_[3];
    double vel_std_[3];
    double atti_std_[3];*/
  long mode;
} NavPva;
typedef enum {
  UseGiven = 0,
  Moving = 1,
  Static = 2
} AlignMode;

typedef struct {
  ImuPara imuPara;
  int imu_data_rate;
  int align_mode;
//  NavPva init_epoch;
  int nhc_enable;
  float nhc_var;
  int zupt_enable;
  float zupt_var;
  float zupta_var;
  float antenna_arm[3];
  int odo_enable;
  float odo_var;
  float odo_kd;
  float odo_wheel_radius;
  int enable_gnss;
} Option;

/*typedef struct {
  unsigned char year;
  unsigned char mon;
  unsigned char day;
  unsigned char hour;
  unsigned char minute;
  unsigned char second;
} DateTime;*/
typedef struct {
  unsigned char  vh_;
  unsigned char vl_;
  unsigned char ah_;
  unsigned char al_;
  int reserved;
} VelocityRaw;
typedef struct {
  float forward;
  float angular;
} Velocity;
/**
 * CameraInfo from Uart
 */
typedef struct {
  unsigned int Header; /*4*/
  char ImageName[24]; /*24*/
  float Vn[3];/*4*3 = 12*/
  float VnStd[3];/*12*/
  unsigned int crc;/*4*/
} CameraInfo;

typedef struct {
  CameraInfo camera_info_;
  double time_s;
} CameraEvent;

#endif //LOOSELY_COUPLE_H7_NAV_STRUCT_H
